package com.hkts.naturalgas.performance.service.serviceimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hkts.naturalgas.performance.entity.HkAssessmentIndex;
import com.hkts.naturalgas.performance.mapper.HkAssessmentIndexMapper;
import com.hkts.naturalgas.performance.service.IHkAssessmentIndexService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yck
 * @since 2020-12-22
 */
@Service
@Transactional
public class HkAssessmentIndexServiceImpl extends ServiceImpl<HkAssessmentIndexMapper, HkAssessmentIndex> implements IHkAssessmentIndexService {


@Autowired
private HkAssessmentIndexMapper hkAssessmentIndexMapper;

@Override
public IPage<HkAssessmentIndex> selectPage(Page<HkAssessmentIndex> page, HkAssessmentIndex hkAssessmentIndex){
        QueryWrapper<HkAssessmentIndex> query = Wrappers.query();
        QueryWrapper<HkAssessmentIndex> entityWrapper = getEntityWrapper(query, hkAssessmentIndex);
        return hkAssessmentIndexMapper.selectPage(page, entityWrapper);
        }




@Override
public List<HkAssessmentIndex> selectList(HkAssessmentIndex hkAssessmentIndex){
        QueryWrapper<HkAssessmentIndex> query = Wrappers.query();
        QueryWrapper<HkAssessmentIndex> entityWrapper = getEntityWrapper(query, hkAssessmentIndex);
        return hkAssessmentIndexMapper.selectList(entityWrapper);
        }

/**
 *  公共查询条件
 * @param entityWrapper
 * @return
 */
public QueryWrapper<HkAssessmentIndex> getEntityWrapper(QueryWrapper<HkAssessmentIndex> entityWrapper,HkAssessmentIndex hkAssessmentIndex){
        //条件拼接
                if(StringUtils.isNotBlank(hkAssessmentIndex.getCreateBy())){
                entityWrapper.like(HkAssessmentIndex.CREATE_BY,hkAssessmentIndex.getCreateBy());
                }
         /*       if(StringUtils.isNotBlank(hkAssessmentIndex.getCreateTime())){
                entityWrapper.like(HkAssessmentIndex.CREATE_TIME,hkAssessmentIndex.getCreateTime());
                }
                if(StringUtils.isNotBlank(hkAssessmentIndex.getDelFlag())){
                entityWrapper.like(HkAssessmentIndex.DEL_FLAG,hkAssessmentIndex.getDelFlag());
                }
                if(StringUtils.isNotBlank(hkAssessmentIndex.getUpdateBy())){
                entityWrapper.like(HkAssessmentIndex.UPDATE_BY,hkAssessmentIndex.getUpdateBy());
                }
                if(StringUtils.isNotBlank(hkAssessmentIndex.getUpdateTime())){
                entityWrapper.like(HkAssessmentIndex.UPDATE_TIME,hkAssessmentIndex.getUpdateTime());
                }
                if(StringUtils.isNotBlank(hkAssessmentIndex.getIndexDescribe())){
                entityWrapper.like(HkAssessmentIndex.INDEX_DESCRIBE,hkAssessmentIndex.getIndexDescribe());
                }
                if(StringUtils.isNotBlank(hkAssessmentIndex.getIndexName())){
                entityWrapper.like(HkAssessmentIndex.INDEX_NAME,hkAssessmentIndex.getIndexName());
                }
                if(StringUtils.isNotBlank(hkAssessmentIndex.getIndexScore())){
                entityWrapper.like(HkAssessmentIndex.INDEX_SCORE,hkAssessmentIndex.getIndexScore());
                }*/
        return entityWrapper;
        }
        }
